package engine.tip.tipItem
{
	import engine.data.ObjectData;
	import engine.tip.TipsMainLogic;
	
	import newx.com.config.StaticIni;
	
	public class KungfuItem extends BaseTipItem
	{
		/**
		 *属性：KungFuQuality
			值2： 绿色
			值3： 蓝色
			值4： 紫色
			值5：黄色
 
		 */		
		public static const GRAY:int=1,
								RED:int=2,
								GREEN:int=3,
								BLUE:int=4,
								PURPLE:int=5,
								YELLOW:int=6,
								EX_YELLOW:int=7;
		public static const COLOR_ARR:Array=["ADADAD","888888","ff03ed","00cc66","20bff8","a335ee","ffff00"];
		protected var levelNeedExp:Object;
		private static var countConfig:Object;
		private	var KungFuMax:int;
		private var kungfuCurrent:int;
		/**
		 *ClassID:132,
			WorldUID:EED82DCF3ACB4E71A21490C2F9CD1487,
			ConfigID:7603012,
			Photo:48001066,
			KungFuQuality:3,
			KungFuAddPropName:PhyGuardProbAdd,
			KungFuPrize:12000,
			KungFuInitExp:60, 
		 * @param dataObject
		 * @param data
		 * 
		 */		
		public function KungfuItem(dataObject:ObjectData=null, data:Object=null)
		{
			super(dataObject, data);
		}
		override public function getMainStr():String
		{
			if(quality=="2")
				return StaticIni.getSwfLangStr("Des_7605018");
			return getName()+getChangeLine()
				+getLevel()
//				+getQuality()
				+getExp()
				+singleProperty;
//				+getPrice();
		}
		override protected function setPic():void
		{
			_panel.addPicFree(null,0,0);
		}
		public function getLevel():String
		{
			return  StaticIni.getSwfLangStr("ItemDes_NeedLevel")+(level+getChangeLine());
		}
		public function getLevel2():String
		{
			return 	getColorHtml("Lv."+level,COLOR_ARR[quality])
		
		}
		public function get level():int
		{
			return (int(data["KungFuLevel"])+1);
		}
		public function getQuality():String
		{
			return "品质： "+quality+getChangeLine()
		}
		/**
		 *品质 
		 * @return 
		 * 
		 */		
		public function get quality():String
		{
			return data["KungFuQuality"]
		}
		public function getExp():String
		{
			KungFuMax=0
			if(!levelNeedExp)
			{
				levelNeedExp=TipsMainLogic.instance.getStaticObjWithID("KungFuLevelExp");
			}
			if(levelNeedExp[quality])
			{
				kungfuCurrent=data["KungFuExp"]
				var arr:Array=String(levelNeedExp[quality]).split(",");
				KungFuMax=arr[int(data["KungFuLevel"])]
//				for (var i:int = 0; i <= int(data["KungFuLevel"]); i++) 
//				{
//					KungFuMax+=int(arr[i])
//					if(data["KungFuLevel"]!=i)
//					{
//						kungfuCurrent+=int(arr[i]);
//					}
//				}
			}
			return StaticIni.getSwfLangStr("Kungfu_UIString22")+kungfuCurrent+"/"+KungFuMax+getChangeLine();
		}
		/**
		 *功法当前经验 
		 * @return 
		 * 
		 */		
		public function get kungfuCurrentExp():int
		{
			getExp()
			return kungfuCurrent
		}
		/**
		 *功法当前最大经验 
		 * @return 
		 * 
		 */		
		public function get kungfuMaxExp():int
		{
			getExp();
			return KungFuMax
		}
		/**
		 *初始经验 
		 * @return 
		 * 
		 */		
		public function get kungfuInitExp():int
		{
			return data["KungFuInitExp"]
		}
		/**
		 *得到到下一集 需要多少经验 
		 * @return 
		 * 
		 */		
		public function get needExpToNext():int
		{
		return	kungfuMaxExp-kungfuCurrentExp;
		}
		/**
		 *模拟增加经验  
		 * @param exp  增加经验
		 * @return 增加经验后 应为多少级
		 * 
		 */		
		public function addExUptoLevel(exp:int):int
		{
			getExp();
			var currentExp:int=kungfuCurrent;
			var maxExp:int=KungFuMax;
			var lvl:int=data["KungFuLevel"];
			var arr:Array=String(levelNeedExp[quality]).split(",");
			currentExp+=exp;
			while(maxExp<=currentExp&&arr.length>lvl)
			{
				maxExp=int(arr[++lvl]);
			}
			return lvl+1;
		}
		public function get singleProperty():String
		{
			countConfig==null?countConfig=TipsMainLogic.instance.getStaticObjWithID("KungFuProperty"):null;
			var arr:Array=String(countConfig[configId]).split(",");
			var fir:int=arr[0];
			var upGrand:int=arr[1];
			var totalCount:int=int(arr[0])+int(data["KungFuLevel"])*upGrand;
			return getPropertyColor(StaticIni.getSwfLangStrVar("Item_"+data["KungFuAddPropName"],[totalCount]))//+getChangeLine();
		}
		override public function getPrice():String
		{
			var str:String="";
			str = str.concat(StaticIni.getSwfLangStr("UIStr_1000296"));
			str = str.concat(data["KungFuPrize"]);
			str = str.concat(StaticIni.getSwfLangStr("Tips_CapitalType0"));
			return str;
		}
		public function getLittleStr():String
		{
			return getColorName()+"  "+getLevel2()+"  "+singleProperty;
//			return getLevel2()+"\t"+getColorName()
		}
		override public function getName():String
		{
			return StaticIni.getSwfLangStrVar("Tips_name",[
				getColorName()
			]);
		}
		public function get describle():String
		{
			return StaticIni.getSwfLangStr("Des_"+configId);
		}
		public function getColorName():String
		{
			return getColorHtml(getNormalName(),COLOR_ARR[quality])
		}
		
	}
}